const axios = require('axios');
const UserAgents = require('user-agents');

const userAgents = new UserAgents({
	deviceCategory: 'desktop'
});

const request = axios.create({
	timeout: 10000
});

const pickData = res => res.data;

class Finder {
	constructor() {
		this.name = 'finder';
	}

	async load(url, options) {
		const headers = {
			'User-Agent': userAgents.toString(),
			Cookie: options.cookie || null
		};

		const html = await request.get(url, {
			headers
		}).then(pickData).catch(e => {
			console.log(e)
		});

		return html;
	}
}

module.exports = Finder;